<template>
	<!-- 访问记录 -->
	<div>
		<div class="edit-top">
			添加信息
			<i class="el-icon-close" @click='cancel'></i>
		</div>
		<div class="edit-content">
			<div class="edit-title">回访信息</div>
			<div class="edit-item">
				<label>回访类型</label><select v-model="info.visitType">
				<option value="1" >首次拜访</option>
				<option value="3" >三日回访</option>
				<option value="7" >周回访</option>
				<option value="30" >月回访</option>
				</select>
			</div>
			<div class="edit-item">
				<label>回访时间</label><el-date-picker
				      v-model="info.visitDate"
				      type="datetime"
					  value-format="yyyy-MM-dd HH:mm:ss"
				      placeholder="回访时间">
				 </el-date-picker>
			</div>
			<div class="edit-item">
				<label style="float: left;">回访内容</label><textarea v-model="info.visit" rows="6" />
			</div>
			
			
		</div>
		<div class="edit-bottom">
			<span @click='cancel'>取消</span>
			<el-button @click='save' type="primary">保存</el-button>
		</div>
	</div>
</template>

<script>
	let _this;
	export default {
		props:['id'],
		data() {
			return {
				info: {
					id:'',
					visitType: "1",
					visit: '',
					visitDate: '',
				}
			}
		},
		created() {
			_this = this;
		},
		mounted() {
		},
		methods: {
			save() {
				if (this.info.visit == "") {
					this.$popup.open('内容不能为空');
					return;
				}
				if (this.info.visitDate == "") {
					this.$popup.open('时间不能为空');
					return;
				}
				this.info.crmPassengerId = this.id;
				this.$axios.post(this.$global.serverIp + 'crm/crmvisitrecords/save', _this.info)
					.then(function(res) {
						if (res != '') {
							_this.success('添加成功');
						}
					})
			},
			success(content) {
				this.$alert(content, '提示', {
					confirmButtonText: '确定',
					callback: action => {
						_this.$emit("saveFangwen", 2);
					}
				});
			},
			cancel() {
				this.$emit("saveFangwen", 1);
			}
		}
	}
</script>

